// 整合html字符串
export const html_encode = (str:string | any) => {
    var s = "";
    if (str.length == 0)
    return "";
    s = str.replace(/</g, "&lt;");
    s = s.replace(/>/g, "&gt;");
    s = s.replace(/ /g, "&nbsp;");
    s = s.replace(/\'/g, "&#39;");
    s = s.replace(/\"/g, "&quot;");
    s = s.replace(/\n/g, "<br>");
    return s;
}

// 解析html字符串
export const html_decode = (str:string | any) => {
    var s = "";
    if (str.length == 0)
    return "";
    s = str.replace(/&lt;/g, "<");
    s = s.replace(/&gt;/g, ">");
    s = s.replace(/&nbsp;/g, " ");
    s = s.replace(/&#39;/g, "\'");
    s = s.replace(/&quot;/g, "\"");
    s = s.replace(/<br>/g, "\n");
    return s;
}



// 特殊处理
export const html_encode2 = (str:string | any) => {
    var s = "";
    if (str.length == 0) return "";
    s = str.replace(/<p>/g, "");
    s = s.replace(/<\/p>/g, "");
    s = s.replace(/<strong>/g, "");
    s = s.replace(/<\/strong>/g, "");
    s = s.replace(/ /g, "&nbsp;");
    s = s.replace(/\'/g, "&#39;");
    s = s.replace(/\"/g, "&quot;");
    s = s.replace(/\n/g, "<br>");
    s = s.replace(/=/g, "&#61;");
    s = s.replace(/\(/g, "&#40;");
    s = s.replace(/\)/g, "&#41;");
    s = s.replace(/\?/g, "&#63;");
    return s;
}


// 解析html字符串
export const html_decode2 = (str:string | any) => {
    var s = "";
    if (str.length == 0)return "";
    s = str.replace(/&nbsp;/g, " ");
    s = s.replace(/&#39;/g, "\'");
    s = s.replace(/&quot;/g, "\"");
    s = s.replace(/<br>/g, "\n");
    s = s.replace(/&#61;/g, "=");
    s = s.replace(/&#40;/g, "(");
    s = s.replace(/&#41;/g, ")");
    s = s.replace(/&#63;/g, "?");
    return s;
}